<%-- 
    Document   : log01021
    Created on : Nov 18, 2012, 10:08:33 AM
    Author     : Cimela
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <c:if test="${empty sessionScope.USER}">
        <jsp:forward page="${index.jsp}"/>
    </c:if>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Timesheet</title>
    </head>
    <body>
        <script>
            function validate(form){
                var DURATION = "^[1-8]";
                
            }
        </script>
        <h1>Timesheet</h1>
         <form action="TimesheetController" method="POST">
            From: <input type="text" name="txtFrom" placeholder="dd/MM/yyyy"/>
            To:   <input type="text" name="txtTo" placeholder="dd/MM/yyyy"/>
            Project:
            <c:set var="pjlist" value="${sessionScope.listPj}"  ></c:set>
            <select name="cbProject" style ="width: 150px">
                <option value="All">All</option>
                <x:forEach var="proj" select="$doc//project">
                    <option value="$proj/name" ><x:out select="$proj/name"/></option>
                </x:forEach>
            </select>
            Status:
            <select name="cbStatus" >
                <option value="All">All</option>
                <option value="approved">approved</option>
                <option value="unapproved">unapproved</option>
                <option value="rejected">rejected</option>
            </select>
            <input type="submit" name="btAction" value="Search" />
        </form>
        <br/>
        
        <c:set var = "info" value="${requestScope.listUpdate}"/>
        <c:if test ="${not empty info}">
            <form action="UpdateTimesheetsController" >
                <table border="1">
                    <thead>
                        <tr>
                            <th>No</th>
                            <th>Date</th>
                            <th>Description</th>
                            <th>Project</th>
                            <th>Duration</th>
                        </tr>
                    </thead>
                    <tbody>
                        <c:forEach var="timesheet" items="${info}" varStatus="counter">
                            <tr>
                                <td width="15px"> ${counter.count}
                                     <input type="hidden" name="txtID" value="${timesheet.id}" /></td>
                                <td> <input style="width: 100px" type="text" name="txtDate" value="${timesheet.datetime}"/> </td>
                                <td> <input style="width: 300px" type="text" name="txtDes" value="${timesheet.description}"/> </td>
                                <td> <select style="width: 200px" name="Project" style="width: 200px" >
                                        <c:if test="${not empty pjlist}" >
                                            <c:forEach var="proj" items="${pjlist}">
                                                <option value="${proj.name}" <c:if test="${ timesheet.project == proj.name }" > selected="true" </c:if> >${proj.name}</option>
                                            </c:forEach>
                                        </c:if>
                                     </select>  </td>
                                <td> <input type="text" name="txtDuration" value="${timesheet.duration}"/> </td>
                            </tr>
                        </c:forEach>
                    </tbody>
                </table>
                <br/>
                <input type="submit" name="btAction" value="Submit"/>
                <input type="submit" name="btAction" value="Back"/>
            </form>
        </c:if>
    </body>
</html>
